<template>
  <el-dialog
    top="30px"
    width="80%"
    class="dialog-sm"
    append-to-body
    :close-on-click-modal="false"
    :before-close="beforeClose"
    :visible.sync="visible"
  >
    <el-tabs>
      <el-tab-pane label="审批登记" v-if="+type !== 2">
        <register-contract-edit
          :related-data="relatedData"
          :viewModel="viewModel"
          @success="handleEditSuccess"
        ></register-contract-edit>
      </el-tab-pane>
      <el-tab-pane label="放款登记" v-else>
        <register-contract-edit-replay
          :related-data="relatedData"
          @dismiss="beforeClose"
          @success="handleEditSuccess"
        ></register-contract-edit-replay>
      </el-tab-pane>
      <!-- <el-tab-pane label="放款通知书"
                   v-if="showNotice">
        <register-loan-notice :visible="true"
                              :related-data="relatedData"
                              :view-mode="false"
                              @success="handleEditSuccess"
                              v-if="hasContract&&!hasRegister"></register-loan-notice>
      </el-tab-pane> -->
    </el-tabs>
  </el-dialog>
</template>

<script>
import RegisterContractEdit from '@/bank/views/mission/RegisterContractEdit'
import RegisterContractEditReplay from '@/bank/views/mission/RegisterContractEditReplay'

export default {
  components: {
    RegisterContractEdit,
    RegisterContractEditReplay,
  },
  props: {
    viewModel: Boolean,
    type: String,
    visible: Boolean,
    relatedData: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {}
  },
  computed: {
    relatedId() {
      return this.relatedData.customer_related_id || ''
    },
  },
  watch: {
    // relatedData: {
    //   handler: function () {
    //     this.getData()
    //   },
    //   deep: true,
    //   immediate: true
    // }
  },
  created() {},
  mounted() {},
  methods: {
    beforeClose() {
      this.$emit('update:visible', false)
    },

    handleEditSuccess() {
      this.beforeClose()
      this.$emit('success', true)
    },

    // async getData() {
    //   this.contractLoading = true
    //   await this.$utils.promise(Promise.all([
    //     this.$store.dispatch('getEntrustContract', this.relatedId)
    //   ]))
    //   this.contractLoading = false
    // }
  },
}
</script>
<style lang="scss" scoped></style>
